package com.yann.bomb.crud;

import com.yann.bomb.BaseActivity;
import com.yann.bomb.R;
import com.yann.bomb.crud.bean.Category;
import com.yann.bomb.util.LogUtils;
import com.yann.bomb.util.ToastUtils;

import java.util.List;

import cn.bmob.v3.BmobQuery;
import cn.bmob.v3.exception.BmobException;
import cn.bmob.v3.listener.FindListener;

/**
 * Created by yayun.xia on 2018/11/27
 */
public class FindActivity extends BaseActivity {

    @Override
    public int intiLayout() {
        return R.layout.activity_find;
    }

    @Override
    public void initView() {
        setTitle("查询");
    }

    @Override
    public void initData() {

    }


    /**
     * 查询多条数据
     */
    private void query() {
        BmobQuery<Category> bmobQuery = new BmobQuery<>();
        bmobQuery.findObjects(new FindListener<Category>() {
            @Override
            public void done(List<Category> categories, BmobException e) {
                if (e == null) {
                    ToastUtils.showLong("查询成功：" + categories.size());
                } else {
                    LogUtils.e("BMOB", e.getMessage());
                    ToastUtils.showLong(e.getMessage());
                }
            }
        });
    }
}
